import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn, BaseEntity } from 'typeorm';
import { User } from './user.entity';

/**
 * 通知类型枚举
 */
export enum NotificationType {
  TASK_ASSIGNMENT = 'task_assignment',  // 任务分配
  TASK_COMMENT = 'task_comment',        // 任务评论
  COMMENT_REPLY = 'comment_reply',      // 评论回复
  TASK_DUE_DATE = 'task_due_date',      // 任务截止日期
}

/**
 * 源对象类型枚举
 */
export enum SourceType {
  TASK = 'task',
  COMMENT = 'comment',
  REPLY = 'reply',
}

/**
 * 通知实体
 */
@Entity('notifications')
export class Notification extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 100 })
  title: string;

  @Column({ type: 'text' })
  content: string;

  @Column({
    type: 'enum',
    enum: NotificationType,
  })
  type: NotificationType;

  @Column()
  userId: string;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'userId' })
  user: User;

  @Column()
  sourceId: string;

  @Column({
    type: 'enum',
    enum: SourceType,
  })
  sourceType: SourceType;

  @Column({ default: false })
  isRead: boolean;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
} 